﻿<!--  
//ds_project:项目表结构：主键，项目编号	项目名称UTF8(40个字符)) 
//ds_project:向目表结构：project_id 	project_name 

//ds_category:分类表结构：分类编号		分类名称			隶属于项目的ID
//ds_category:分类表结构：category_id	category_name 	belong_project_id 

//ds_address:网址表结构：地址编号		地址名称			网址详情			分类ID				
//ds_address:网址表结构：address_id 	address_name 	address_http 	address_cate_id 	
-->
<?php
	if ( array_key_exists ( '_submit_check', $_POST ) )
	{
		if ( $_POST [ 'addr_name' ] != '' && $_POST [ 'addr_http' ] != '' &&  $_POST [ 'addr_cate_id' ] !='' )
		{
			$query = 	"INSERT INTO 
						`ds_address` 
						(
							`address_name`, 
							`address_http`,
							`address_cate_id`
						) 
					VALUES 
						(
							'" . mysql_real_escape_string ( $_POST ['addr_name'] ) . "', 
							'" . mysql_real_escape_string ( $_POST ['addr_http'] ) . "',
							'".mysql_real_escape_string ( $_POST ['addr_cate_id'] ) . "'
						)";

			if ( @mysql_query ( $query ,$con ) )
			{
				$success='add new addree succes!';
			}
			else {
				showAlert('add new addr Fail!');
				die ( mysql_error () );
			}
		}
		else {
			echo 'Please ensure that you have a title and some content for this article!<br>';
		}
	}

	if ( isset ( $success ) ) {
		showAlert($success);
		echo "<script>
window.location.reload(true);
</script>";

	}
	else {
	//we need this form only if we don't have the success message
?>
	<form id="insert" name="insert" method="post" action="<?=$_SERVER['PHP_SELF']?>">
		<input type="hidden" name="_submit_check" value="1"/> 
		<strong>地址名称:</strong><br />
		<input name="addr_name" type="text" id="addr_name" size="55" value="<?php if ( isset ( $_POST['addr_name'] ) ): echo $_POST['addr_name']; endif; ?>" />
        <input type="hidden" name="_submit_check" value="1"/> 
		<br />类别ID:<br />
		<input name="addr_cate_id" type="text" id="addr_cate_id" size="55" value="<?php if ( isset ( $_POST['addr_cate_id'] ) ): echo $_POST['addr_cate_id']; endif; ?>" />
		<br />网址:<br />
		<textarea name="addr_http" cols="55" rows="5" id="addr_http"><?php if ( isset ( $_POST['addr_http'] ) ): echo $_POST['addr_http']; endif; ?></textarea>
			<br />
		<input type="submit" name="Submit" value="确定" />
	</form>
<?php } ?>